package com.qfedu.sca.filter;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * 千锋Java,为你而生！
 *
 * @Author: Feri
 * @Date:2024/11/11 10:14
 * @Modified:
 */
@Component //IOC创建类的对象
public class HelloFilter implements GlobalFilter {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        ServerHttpRequest request=exchange.getRequest();
        ServerHttpResponse response=exchange.getResponse();
        System.err.println("请求路径："+request.getURI().toString());
        System.err.println("请求消息头："+request.getHeaders().get("scatoken"));

        //放行
        return chain.filter(exchange);
    }
}
